package practice;

import java.util.Arrays;

/**
 * 数组的复制
 * @author: yyfei  
 * @email:  yyfei123@qq.com
 */
public class ArrayCopy {
	public static void main(String[] args) {
		int[] arr= new int[] {1,2,3,4,5,6};
		//复制数组
		int[] arr_new=copyArray(arr);
		System.out.println(	Arrays.toString(arr));
	    System.out.println(	Arrays.toString(arr_new));
		
	    //使用Arrays 工具类 复制数组，Arrays.copyof(); 也能对数组进行扩容
	    System.out.println( Arrays.toString(Arrays.copyOf(arr, arr.length+3)));
	    
	}
	
	/**
	 * 复制数组
	 * @author: yyfei
	 * @email:  yyfei123@qq.com
	 */
	public static int[] copyArray(int[] arr) {
		int[] arr_new=new int[arr.length];
		
		for (int i = 0; i < arr.length; i++) {
			arr_new[i]=arr[i];
		}
		return arr_new;
	}
	
	
}
